/** 处理异步问题 */
import { Component, ComputedOptions, MethodOptions, type App } from "vue";

export default async function () {
  const components = import.meta.glob("./*/index.vue");
  const componentList: any = [];
  for (const key in components) {
    const element = components[key];
    const component: any = await element();
    componentList.push(component.default);
  }
  return {
    install: (app: App) => {
      componentList.forEach((element: Component<any, any, any, ComputedOptions, MethodOptions>) => {
        if (element.name) {
          app.component(element.name, element);
        }
      });
    }
  }
}
